home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / SeqPups / appsrc / autoseq.src / FileFormat.H < prev    next >
Text File  |  1996-07-05  |  3KB  |  83 lines

  1. //    ============================================================================
  2. //    FileFormat.H                                                    80 columns
  3. //    Reece Hart    (reece@ibc.wustl.edu)                                tab=4 spaces
  4. //    Washington University School of Medicine, St. Louis, Missouri
  5. //    This source is hereby released to the public domain.  Bug reports, code
  6. //    contributions, and suggestions are appreciated (to email address above).
  7. //    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -    -
  8. //    This code defines tracefile format types, user-interface descriptors for
  9. //    each format, and declares a function (defined in FileFormat.C) which
  10. //    attempts to guess the format of a named file.
  11. //
  12. //    This code is a complete rewrite of an analogous function for ted
  13. //    ("Trace EDitor") by Roger Staden et al.
  14. //    ========================================|===================================
  15.  
  16. #ifndef _H_FileFormat                        // include this file only once
  17. #define _H_FileFormat
  18.  
  19. //
  20. // As file types are added, append the internal abbrevation to the list of
  21. // enums, and append a corresponding <abbrev,descr> pair to the array of
  22. // TRACEFILE_FORMATS.
  23. // Code for reading and/or writing the format should be placed in CTraceFile::
  24. // Read(filename,fmt), Write(filename,fmt), Read(FILE*,fmt) and Write(FILE*,fmt)
  25. //
  26. enum    format_t
  27.         {
  28.         ABI0,                                // first trace set (raw data)
  29.         ABI1,                                // second trace set (mobility?)
  30.         ABI,                                // third trace set (processed data)
  31.         ALF,
  32.         SCF,
  33.  
  34.         // insert new internal file type id's just above this line
  35.         // notice that unknown = the number of format types
  36.         unknown,
  37.         FFerr
  38.         };
  39.  
  40. static const MAX_ABBR_LENGTH = 5;
  41. static const MAX_DESC_LENGTH = 50;
  42. static const struct
  43.     {
  44.     char    abbr[MAX_ABBR_LENGTH];
  45.     char    desc[MAX_DESC_LENGTH];
  46.     }
  47.     TRACEFILE_FORMATS[] =
  48.     {
  49.         { "ABI0",    "ABI (raw data)" },
  50.         { "ABI1",    "ABI (2nd trace set)" },
  51.         { "ABI",    "ABI (processed data)" },
  52.         { "ALF",    "ALF" },
  53.         { "SCF",    "Standard Chromatogram Format" },
  54.  
  55.         // insert new <abbr,desc> pairs just above this line
  56.         { "unk",    "unknown/unspecified" },
  57.         { "err",    "error" }
  58.     };
  59.  
  60.     
  61. // FileFormatAbbr
  62. // return a string which gives the abbreviation of the format
  63. inline
  64. const char*
  65. FileFormatAbbr(format_t fmt)
  66.     {
  67.     return (char*)&TRACEFILE_FORMATS[fmt].abbr;
  68.     }
  69.  
  70. // FileFormatDesc
  71. // return a string which gives the name of the format
  72. inline
  73. const char*
  74. FileFormatDesc(format_t fmt)
  75.     {
  76.     return (char*)&TRACEFILE_FORMATS[fmt].desc;
  77.     }
  78.  
  79. format_t    FileFormat(const char* filename);    // Guess format of filename
  80.                                                 // see FileFormat.C
  81.  
  82. #endif                                        // conditional inclusion
  83.